package com.zjmy.component;

import com.lgCore.client.SxRpcTcpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


/**
 * 初始化服务 ApplicationContext被初始化后触发监听
 */
@Component
public class InitListener implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(InitListener.class);

    @Value("${rpc.zk.registry.services}")
    private String zkRegistry;

    @Value("${rpc.netty.client.isRun}")
    private boolean clientIsRun;

    @Value("${rpc.SystemRegion}")
    private String systemRegion;

    @Value("${spring.profiles.active}")
    private String profilesActive;

    @Override
    public void run(String... args) throws Exception {
        log.info("初始化服务 start...");
//        //启动rpc客户端
        if(clientIsRun){
            SxRpcTcpClient sxRpcClient = new SxRpcTcpClient(zkRegistry,systemRegion,profilesActive);
            sxRpcClient.start();
        }

    }


}




